/**
 *  MESH channel supports mrmc
 *	Author: jt.zheng
 *	Date: 2010/11/15
 *
 */

#ifndef ns_mrmc_meshchannel_h
#define ns_mrmc_meshchannel_h

#include "channel.h"
#include "mesh_phy.h"

class MrmcMeshChannel :public Channel {
	friend class Topography;
public:
	MrmcMeshChannel (void);
	virtual int command(int argc, const char*const* argv);
        inline double gethighestAntennaZ() { return highestAntennaZ_; }

private:
	void sendUp(Packet* p, Phy *txif);
	double get_pdelay(Node* tnode, Node* rnode);
	
	/* For list-keeper, channel keeps list of mobilenodes 
	   listening on to it */
	int numNodes_;
	MobileNode *xListHead_;
	bool sorted_;
	void addNodeToList(MobileNode *mn);
	void removeNodeFromList(MobileNode *mn);
	void sortLists(void);
	void updateNodesList(class MobileNode *mn, double oldX);
	MobileNode **getAffectedNodes(MobileNode *mn, double radius, int *numAffectedNodes);

	MeshPhy* phy_ ;
	
protected:
	static double distCST_;        
        static double highestAntennaZ_;
        void calcHighestAntennaZ(Phy *tifp);
};
#endif //_meshchannel_h
